#include <bits/stdc++.h>
using namespace std;

char buf[(int)3e7], *fs = buf;

inline int gn() {
    int k = 0;
    char c = *fs++;
    for (; !isdigit(c); c = *fs++);
    for (; isdigit(c); c = *fs++) k = k * 10 + c - '0';
    return k;
}

int n, m;

priority_queue<int, vector<int>, less<int> > q;
queue<int> tmp;

int main() {
    freopen("in", "r", stdin);
    fread(buf, 1, (int)3e7, stdin);
    n = gn(), m = gn();    
    for (int i = 1; i <= n; i++)
        q.push(gn());
    // while (!q.empty()) {
        // cout << q.top() << '\n';
        // q.pop(); 
    // }
    for (int i = 1; i <= m; i++) {
        int c = gn();
        for (int j = 1; j <= c; j++) {
            if (q.empty() or !q.top())
                return printf("%d\n", i - 1), 0;
            int k = q.top();
            q.pop();
            tmp.push(k - 1);
        }
        while (!tmp.empty()) {
            q.push(tmp.front());
            tmp.pop();
        }
    }
    cout << m << '\n';
}
